package kr.hkit.androidcomplete03.ch281.common;

import java.util.ArrayList;
import java.util.zip.Inflater;

import kr.hkit.androidcomplete03.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class DaeguNoticeAdapter extends BaseAdapter {
	Context context;
	ArrayList<DaeguNoticeItem> itemLists;
	private LayoutInflater inflater;
	
	public DaeguNoticeAdapter(Context context,
			ArrayList<DaeguNoticeItem> itemLists) {
		super();
		this.context = context;
		this.itemLists = itemLists;
		inflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		return itemLists.size();
	}

	@Override
	public Object getItem(int index) {
		// TODO Auto-generated method stub
		return itemLists.get(index).getTitle();
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if(convertView == null){
			convertView = inflater.inflate(R.layout.ch281_xmlparser_itemlow, parent, false);
		}
		
		TextView itemTitle = (TextView) convertView.findViewById(R.id.ch281_daegu_title);
		TextView itemSubtitle = (TextView) convertView.findViewById(R.id.ch281_daegu_subtitle);
		
		itemTitle.setText(itemLists.get(position).getTitle());
		itemSubtitle.setText(itemLists.get(position).getSubTitle());

		
		return convertView;
	}

}
